import request from '@/config/axios'

/** 用户信息 */
export interface User {
          id: number; // 主键ID
          userName?: string; // 用户名称
          phone?: string; // 用户手机号
          address: string; // 用户地址
          wechatOpenid: string; // 用户微信openid
  }

// 用户 API
export const UserApi = {
  // 查询用户分页
  getUserPage: async (params: any) => {
    return await request.get({ url: `/java/user/page`, params })
  },

  // 查询用户详情
  getUser: async (id: number) => {
    return await request.get({ url: `/java/user/get?id=` + id })
  },

  // 新增用户
  createUser: async (data: User) => {
    return await request.post({ url: `/java/user/create`, data })
  },

  // 修改用户
  updateUser: async (data: User) => {
    return await request.put({ url: `/java/user/update`, data })
  },

  // 删除用户
  deleteUser: async (id: number) => {
    return await request.delete({ url: `/java/user/delete?id=` + id })
  },

  /** 批量删除用户 */
  deleteUserList: async (ids: number[]) => {
    return await request.delete({ url: `/java/user/delete-list?ids=${ids.join(',')}` })
  },

  // 导出用户 Excel
  exportUser: async (params) => {
    return await request.download({ url: `/java/user/export-excel`, params })
  },
}
